package com.jwtproject.bootserver.service.impl;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.jwtproject.bootserver.exception.ProjectException;
import com.jwtproject.bootserver.mapper.UserMapper;
import com.jwtproject.bootserver.model.User;
import com.jwtproject.bootserver.service.UserService;
import com.jwtproject.bootserver.status.ProjectStatusEnum;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService  {

    @Override
    public User getEmpByUsername(String username) throws ProjectException {
        EntityWrapper<User> wrapper = new EntityWrapper<>();
        wrapper.eq("account",username);
        User user = this.selectOne(wrapper);
        if(ObjectUtil.isEmpty(user)){
            throw new ProjectException(ProjectStatusEnum.USER_NOT_EXIST);
        }
        return user;
    }
}
